Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

136
Visualizações
parse timestamp into date with AvField[type=date]

I'm using availity-reactstrap-validation module with react library,

I have an AvField[type=date] which I get an timestamp from the API, and I want to parse the date into the AvField's value.

I have formatted the timestamp to this format: YYYY/MM/DD as below:

const scheduleDate = new Date(parseInt(candidateObject.scheduleDate));
scheduleDate: scheduleDate.getFullYear()+"-"+scheduleDate.getMonth()+"-"+scheduleDate.getDate()

And this is the AvField:

<AvField
    name="scheduleDate"
    type="date"
    placeholder=""
    value={innerCandidate.scheduleDate}
    onChange={(e) => {
       setInnerCandidate({
       ...innerCandidate,
       scheduleDate: e.target.value
      })
    }}
 />

for some reason the field remain with his placeholder, but holding the new date in the value.

here is the whole code that receive and update the data:

const CandidateForm = ({candidateObject = {}, history, handleSubmitForm}) => {
    const [innerCandidate, setInnerCandidate] = useState({})
    const [departmentList, setDepartmentList] = useState([])
    const [userPermission, setUserPermission] = useState(0)
    useEffect(() => {
        setUserPermission(localStorage.getItem("permission"));
        if (Object.keys(candidateObject).length > 0) // if exists update the state. //UPDATE COMPONENT
        {
            const scheduleDate = new Date(parseInt(candidateObject.scheduleDate));
            const modifyiedCandidateObject = {
                ...candidateObject,
                scheduleDate: scheduleDate.getFullYear()+"-"+scheduleDate.getMonth()+"-"+scheduleDate.getDate()
            }
            setInnerCandidate(modifyiedCandidateObject)
        }
        // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [candidateObject.id])

    return ()
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda